<template>
  <div class="app-container">
    <div class="head">
      <img src="@/assets/img/Layout/position.png" />
      <p class="see-block">品牌列表</p>
    </div>
    <div class="view-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true">
        <el-form-item label="品牌名称" prop="brandName">
          <el-input
            v-model="queryParams.brandName"
            placeholder="请输入品牌名称检索"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" class="list-search btn-success" color="#5ED4D4">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" class="list-search">重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            class="btn-success"
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="brandAdd()"
            v-hasPermi="['system:brand:add']"
          >新建</el-button>
        </el-col>
      </el-row>
      <el-table v-loading="loading" :data="brandList" @row-click="handleView" :default-sort="{prop: 'date', order: 'descending'}" border>
        <el-table-column label="序号" type="index" align="center" width="50">
           <template slot-scope="scope">
            <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column label="品牌编号" align="center" prop="brandCode" :show-overflow-tooltip="true" sortable />
        <el-table-column label="品牌中文名称" align="center" prop="brandName" :show-overflow-tooltip="true" />
        <el-table-column label="英文名称" align="center" prop="englishName"  :show-overflow-tooltip="true" />
        <el-table-column label="品牌LOGO" align="center" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <img v-if="scope.row.brandUrl" :src="scope.row.brandUrl" width="50" height="50" />
        </template>
        </el-table-column>
        <el-table-column label="状态" align="center" prop="status" width="100">
          <template slot-scope="scope">
              <div v-if="scope.row.status == 0" style="color:#52C41A">启用</div>
              <div v-if="scope.row.status == 1" style="color:#fd562c">禁用</div>
          </template>
        </el-table-column>
        <el-table-column label="品牌简介" align="center" prop="brandIntroduction" :show-overflow-tooltip="true" />
        <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import { listBrand } from "@/api/system/basedata/brand/brand"

export default {
  name: "plan",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 生产列表数据
      brandList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        // 品牌名称
        brandName:undefined
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 获取列表
    getList() {
      this.loading = true
      listBrand(this.addDateRange(this.queryParams)).then(res => {
          this.brandList = res.rows
          this.total = res.total
          this.loading = false
      })
    },
    // 搜索按钮
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    // 重置按钮
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 新建
    brandAdd(){
      this.$router.push({path:"/basedata/brand/add"})
    },
    // 查看详情
    handleView(row) {
      this.$router.push({path:"/basedata/brand/detail",query:{id: row.id}})
    }
  }
}
</script>